home *** CD-ROM | disk | FTP | other *** search
/ USGS: Oil & Gas Potential…National Wildlife Refuge / USGS - Oil & Gas Potential of the Arctic National Wildlife Refuge - Disc 2.iso / mac / MEcode / MEANWR1.txt < prev    next >
Text File  |  1999-02-11  |  20KB  |  649 lines

  1. MEANWR1.doc.
  2.  
  3. ' ANWR Results Program
  4. '  Description: This is a Monte Carlo simulation program to
  5. '    compute estimated in-place and recoverable oil and gas
  6. '    resources by play.
  7. '  Input: Input data is obtained from Excel 97 worksheets Oil,
  8. '    and Play-Prospect.
  9. '  Output: The principal output is specified in worksheet
  10. '    Summary.  It consists of estimates of the mean and
  11. '    standard deviation and selected quartiles of in-place
  12. '    and recoverable oil, NGL, and gas.  Size-frequency
  13. '    distributions are given in worksheet Distns.
  14. '    Supplementary results used to check the program and data
  15. '    are given in worksheet Supple
  16. '    In addition, three ASCII files are created:
  17. '     ProspData is detailed prospects data
  18. '     PlayData is summary data by simulation run
  19. '     HydroData is first 100 records-hydro output for testing
  20. '  Operating instructions: In the Excel 97 Workbook go to
  21. '    Tools, Macro, Macros.  Then run ANWR1_VBA.
  22. '
  23. ' Written in Visual Basic for Applications (Excel 97)
  24. '  John H. Schuenemeyer, USGS, 3/31/98-11:30 am
  25.  
  26. Option Explicit
  27. 'Declarations
  28. Private user_sheet  As Object
  29. Private data_sheet  As Worksheet
  30. Private chart_range As Range
  31. Private chart_sheet As Chart
  32. Private outer_max   As Integer
  33. Private outer_index As Integer
  34. Private inner_max   As Integer
  35.  
  36. Sub ANWR1_VBA()
  37. 'Define variables
  38. Dim i, j, m, ni, nj, fsc, os, minfs, njknt As Integer
  39. Dim r12, orf, grf, fplay As Variant
  40. Dim proboil, adg, adgr, fpros As Variant
  41. Dim GOR, ag, gor1, gor2 As Variant
  42. Dim gast, gastr As Variant
  43. Dim so, sor, nglr1, nglr2 As Variant
  44. Dim sngl, snglr, sg, sgr As Variant
  45. Dim pd, fvf1, fvf2, fvf, depth, depthadd As Variant
  46. Dim nglratio, ngl, nglr, nglt, ngltr As Variant
  47. Dim nglrar As Variant, nglra As Variant
  48. Dim nglrag As Variant, nglrag1 As Variant, nglrag2 As Variant
  49. Dim temp, temp1, temp2 As Variant
  50. Dim press, press1, press2, press3, press4 As Variant
  51. Dim zc As Variant, zc1 As Variant, zc2 As Variant
  52. Dim marray As Integer, seed As Integer
  53. Dim OilR As Variant, OilA As Variant, GasR As Variant, GasA As Variant
  54. Dim ProsDist As Variant, njr As Variant, TotClos As Variant
  55. Dim Mclos As Variant, Ntotc As Integer, Pclos As Variant
  56. Dim mdiv, playa, mplaya As Variant
  57. Dim z(1 To 6), TotR(1 To 7), maxfsc(1 To 14)
  58. Dim TotIP(1 To 7), NumDep(1 To 4), NDRep(1 To 2)
  59. Dim SumIP(1 To 7) As Double, SumR(1 To 7) As Double
  60. Dim Sum2IP(1 To 7) As Double, Sum2R(1 To 7) As Double
  61. Dim tmpIP, tmpR As Variant, c(1 To 7)
  62.  
  63. 'Obtain input values from worksheets
  64.  
  65. Worksheets("Play-Prospect").Activate
  66.  Range("h18").Select
  67.  fplay = Selection.Value  'prob of favorable play
  68.  Range("h24").Select
  69.  fpros = Selection.Value  'prob of favorable prospect
  70.  Range("g30").Select
  71.  proboil = Selection.Value 'prob prospect is oil
  72.  Range("f3").Select
  73.  minfs = Selection.Value   'cutoff value
  74.  Range("j8:k14").Select
  75.  ProsDist = Selection.Value 'num of prospects distn
  76.  
  77. Worksheets("Oil").Activate
  78.   Range("c4").Select
  79.    playa = Selection.Value  'Play area in thousand of acres
  80.   Range("g19").Select
  81.    depthadd = Selection.Value 'Surface to sea level
  82.   Range("c22").Select         ' thousands of feet
  83.    orf = Selection.Value    'oil rcovery factor, %
  84.    orf = orf * 0.01
  85.   Range("c26").Select
  86.    fvf1 = Selection.Value   'fvf equation parameter
  87.   Range("e26").Select
  88.    fvf2 = Selection.Value   'fvf equation parameter
  89.   Range("c29").Select
  90.    gor1 = Selection.Value   'GOR equation parameter
  91.   Range("e29").Select
  92.    gor2 = Selection.Value   'GOR equation parameter
  93.   Range("c31").Select
  94.    nglr1 = Selection.Value  'ngl ratio eqn parameter
  95.   Range("e31").Select
  96.    nglr2 = Selection.Value  'ngl ratio eqn parameter
  97.   Range("j10:u16").Select
  98.    pd = Selection.Value     'hydro volume parameters
  99.    
  100. Worksheets("Gas").Activate
  101.   Range("d19").Select
  102.    grf = Selection.Value   'gas rcovery factor, %
  103.    grf = grf * 0.01
  104.   Range("c23").Select
  105.    nglrag1 = Selection.Value   'ngl+cond to NA gas eqn parameter
  106.   Range("e23").Select
  107.    nglrag2 = Selection.Value   'ngl+cond to NA gas eqn parameter
  108.   Range("d42").Select
  109.    press1 = Selection.Value   'gas press eqn parameter
  110.   Range("f42").Select
  111.    press2 = Selection.Value   'gas press eqn parameter
  112.   Range("d43").Select
  113.    press3 = Selection.Value   'gas press eqn parameter
  114.   Range("f43").Select
  115.    press4 = Selection.Value   'gas press eqn parameter
  116.   Range("d45").Select
  117.    temp1 = Selection.Value   'gas temp eqn parameter
  118.   Range("f45").Select
  119.    temp2 = Selection.Value   'gas temp eqn parameter
  120.   Range("d47").Select
  121.    zc1 = Selection.Value   'gas compress eqn parameter
  122.   Range("f47").Select
  123.    zc2 = Selection.Value   'gas compress eqn parameter
  124.  
  125. Worksheets("Distns").Activate 'In place
  126.   Range("b5:n6").Select
  127.    so = Selection.Value     'store num of dep & total oil
  128.   Range("b9:n12").Select    'gas
  129.    sg = Selection.Value
  130.   Range("b16:n18").Select   'ngl
  131.    sngl = Selection.Value
  132.   Range("b22:n23").Select   'Recoverable
  133.    sor = Selection.Value    'store num of dep & in-place oil
  134.   Range("b26:n29").Select
  135.    sgr = Selection.Value    'gas-recoverable
  136.   Range("b33:n35").Select   'ngl
  137.    snglr = Selection.Value
  138. Worksheets("Supple").Activate  'supplementary results
  139.   Range("e5").Select
  140.    Mclos = Selection.Value
  141.    
  142. 'Clear arrays
  143. marray = 13     'marray is the maximum number of log 2 classes
  144. For j = 1 To marray
  145.  For i = 1 To 2
  146.   so(i, j) = 0
  147.   sor(i, j) = 0
  148.  Next i
  149.  For i = 1 To 3
  150.   sngl(i, j) = 0
  151.   snglr(i, j) = 0
  152.  Next i
  153.  For i = 1 To 4
  154.   sg(i, j) = 0
  155.   sgr(i, j) = 0
  156.  Next i
  157. Next j
  158. For j = 1 To 7
  159.  SumIP(j) = 0
  160.  SumR(j) = 0
  161.  Sum2IP(j) = 0
  162.  Sum2R(j) = 0
  163. Next j
  164. ' The following array stores the maximum field size classes
  165. ' Order is oil,ngl,gas for in place and then recoverable
  166. For i = 1 To 14
  167.  maxfsc(i) = 0
  168. Next i
  169. For i = 1 To 4
  170.  NumDep(i) = 0
  171. Next i
  172. Mclos = 0
  173. Ntotc = 0
  174.  
  175. Open "ProspData" For Output As #1    ' Open file for output.
  176. Write #1, "SimNum", "ProspNum", "O1G2", "O/G", "Closure", "Depth", "Other params"
  177. Open "PlayData" For Output As #2
  178. Write #2, "SimNum", "OilR", "AssDGas", "NA_Gas", "All_Gas", "NGL_ADG", "NGL_NAG", "All_NGL"
  179. Open "HydroData" For Output As #3    ' Open file for output.
  180. Write #3, "SimNum", "ProspNum", "O1G2", "O/G", "Thick", "Closure", "Porosity", "100-WS", "TrapFill"
  181.  
  182. m = 10000  'm is num of simulation runs=num successful plays
  183. mdiv = Int(m / fplay + 0.5) 'total number of plays
  184. seed = -374 'random number seed, negative integer
  185. Rnd (seed)  'initializes uniform random number generator
  186. ' subtraction for computing variance if needed
  187. c(1) = 0 '3500 'est for in place oil mean
  188. c(2) = 0 '1900 'est for in place assoc diss gas mean
  189. c(3) = 0 '10500 'est for in place NA gas mean
  190. c(4) = c(2) + c(3) 'est for in place total gas mean
  191. c(5) = 0 '1900 'est for in place ngl from assoc diss gas mean
  192. c(6) = 0 '10500 'est for in place ngl from NA gas mean
  193. c(7) = c(5) + c(6) 'est for in place total ngl mean
  194.  
  195. 'main simulation loop
  196. For i = 1 To m
  197.  For j = 1 To 7
  198.   TotR(j) = 0
  199.   TotIP(j) = 0
  200.  Next j
  201. NDRep(1) = 0
  202. NDRep(2) = 0
  203. TotClos = 0
  204. njknt = 0
  205. Call SingleS(ProsDist, 1, njr)
  206.  ni = CInt(njr)     'ni is number of prospects, CInt rounds
  207.  
  208. ' Prospect loop
  209. For nj = 1 To ni
  210.  
  211. ' Check favorability of nj th prospect
  212. If Rnd() < fpros Then
  213.  njknt = njknt + 1   'count of successful prospects in play i
  214.  ngl = 0
  215.  nglra = 0
  216.  nglr = 0
  217.  nglrar = 0
  218.  GasA = 0
  219.  adg = 0
  220.  GasR = 0
  221.  adgr = 0
  222.  
  223. ' Is reservoir oil or gas?
  224.  If Rnd() < proboil Then
  225. 'OIL
  226.  
  227.  os = 1     'oil reservoir
  228.   Call SingleS(pd, 11, depth)   'Sample depth
  229.   depth = depth + depthadd
  230. 'In-place oil, mm bbl
  231. 'formation volume factor
  232.   If depth < 2.17 Then     ' thousands of feet
  233.    fvf = 1
  234.   Else
  235.    If depth > 12.15 Then   ' thousands of feet
  236.     fvf = 1.5
  237.      Else
  238.     fvf = fvf1 + fvf2 * depth
  239.    End If
  240.   End If
  241.   
  242.   Call SampleOHVP(z, pd, fvf, minfs)  'get size >=cutoff
  243.   OilA = z(6)
  244.   Call SizeClass(OilA, maxfsc(1), marray, fsc)
  245.   so(1, fsc) = so(1, fsc) + 1
  246.   so(2, fsc) = so(2, fsc) + OilA
  247.   NDRep(1) = NDRep(1) + 1
  248.   TotIP(1) = TotIP(1) + OilA
  249.   
  250. 'in place assoc-dissolved gas, billions of cu. ft.
  251.   GOR = 10 ^ (gor1 + gor2 * depth)
  252.   adg = OilA * GOR * 0.001  '.001 for billions of cu. ft.
  253.   Call SizeClass(adg / 6, maxfsc(2), marray, fsc)
  254.   sg(2, fsc) = sg(2, fsc) + adg
  255.   TotIP(2) = TotIP(2) + adg
  256.     
  257. ' in place ngl from assoc-diss gas, millions bbl
  258.   If depth >= 15.674 Then
  259.     nglratio = 100     'units=bbl/millions cu ft
  260.     Else
  261.     nglratio = 1000000 / (nglr1 * Exp(nglr2 * depth))
  262.   End If
  263.   ngl = adg * nglratio * 0.001 ' ngl, millions bbl
  264.   Call SizeClass(ngl, maxfsc(5), marray, fsc)
  265.   sngl(1, fsc) = sngl(1, fsc) + ngl
  266.   TotIP(5) = TotIP(5) + ngl
  267.   
  268.  ' recoverable oil, mm bbl
  269.  OilR = OilA * orf   ' orf recoverable oil
  270.   Call SizeClass(OilR, maxfsc(8), marray, fsc)
  271.   sor(1, fsc) = sor(1, fsc) + 1
  272.   sor(2, fsc) = sor(2, fsc) + OilR
  273.   TotR(1) = TotR(1) + OilR
  274.   'wellpoil=.16*OilR*z(2) ???
  275.     
  276. ' recoverable assoc-dissolved gas, billions of cu. ft.
  277.   adgr = OilR * GOR * 0.001
  278.   Call SizeClass(adgr / 6, maxfsc(9), marray, fsc)
  279.   sgr(2, fsc) = sgr(2, fsc) + adgr
  280.   TotR(2) = TotR(2) + adgr
  281.   
  282. ' recoverable ngl from assoc-diss gas, millions bbl
  283.   nglr = adgr * nglratio * 0.001
  284.   Call SizeClass(nglr, maxfsc(12), marray, fsc)
  285.   snglr(1, fsc) = snglr(1, fsc) + nglr
  286.   TotR(5) = TotR(5) + nglr
  287.  Else
  288.  
  289.  'GAS
  290.  'Note that provision was made for sampling from
  291.  ' separate distributions for non-associated gas
  292.  ' however in this study all hydrocarbon distributions
  293.  ' are specified on the Oil worksheet.
  294.  os = 2     'code for gas
  295.  Call SingleS(pd, 11, depth)    'Sample depth
  296.  depth = depth + depthadd
  297.  If press4 = 0 Or depth <= 10 Then
  298.   press = press1 + press2 * depth 'Pressure, psi
  299.   Else
  300.   press = press3 + press4 * depth
  301.  End If
  302.  temp = temp1 + temp2 * depth
  303.  Call gasc(press, temp, depth, zc)
  304.  Call SampleGHVP(z, pd, zc, temp, press, minfs)
  305.   GasA = z(6)
  306.   
  307.  ' in place NA gas, billions of cu. ft.
  308.   Call SizeClass(GasA / 6, maxfsc(3), marray, fsc) 'size class
  309.   sg(1, fsc) = sg(1, fsc) + 1
  310.   sg(3, fsc) = sg(3, fsc) + GasA
  311.   NDRep(2) = NDRep(2) + 1
  312.   TotIP(3) = TotIP(3) + GasA
  313.   
  314. '  in place natural gas liquids plus condensate to
  315. '    non-associated gas (bbls/million cf)
  316.   If depth >= 15.674 Then
  317.     nglratio = 100       'units=bbl/million cf
  318.     Else
  319.     nglratio = 1000000 / (nglr1 * Exp(nglr2 * depth))
  320.   End If
  321.   nglra = GasA * nglratio * 0.001  'ngl in mm bbl
  322.   Call SizeClass(nglra, maxfsc(6), marray, fsc) 'size class
  323.   sngl(2, fsc) = sngl(2, fsc) + nglra  'ngl from NA gas
  324.   TotIP(6) = TotIP(6) + nglra 'contribution to ngl from NA gas
  325.   
  326.  ' recoverable NA gas
  327.   GasR = GasA * grf   'recoverable gas, billions cu. ft.
  328.   Call SizeClass(GasR / 6, maxfsc(10), marray, fsc)
  329.   sgr(1, fsc) = sgr(1, fsc) + 1
  330.   sgr(3, fsc) = sgr(3, fsc) + GasR
  331.   TotR(3) = TotR(3) + GasR
  332.   'wellprodg=.62*GasR*z(2)
  333.   
  334.   'recov natural gas liquids plus condensate to
  335.   '  non-associated gas(bbls/million cf)
  336.   nglrar = GasR * nglratio * 0.001  'ngl in mm bbl
  337.   Call SizeClass(nglrar, maxfsc(13), marray, fsc) 'size class
  338.   snglr(2, fsc) = snglr(2, fsc) + nglrar  'ngl from NA gas
  339.   TotR(6) = TotR(6) + nglrar 'contribution to ngl from NA gas
  340.   
  341.  End If     'end of oil/gas computations
  342.  
  343.  'get total gas and total ngl
  344.  gast = adg + GasA      'total in-place gas
  345.  If gast > 0 Then
  346.   Call SizeClass(gast / 6, maxfsc(4), marray, fsc) 'size class
  347.   sg(4, fsc) = sg(4, fsc) + gast
  348.   TotIP(4) = TotIP(4) + gast
  349.   gastr = adgr + GasR    'total recoverable gas
  350.   Call SizeClass(gastr / 6, maxfsc(11), marray, fsc) 'size class
  351.   sgr(4, fsc) = sgr(4, fsc) + gastr
  352.   TotR(4) = TotR(4) + gastr
  353.  End If
  354.  nglt = ngl + nglra     'total in-place ngl
  355.  If nglt > 0 Then
  356.   Call SizeClass(nglt, maxfsc(7), marray, fsc) 'size class
  357.   sngl(3, fsc) = sngl(3, fsc) + nglt
  358.   TotIP(7) = TotIP(7) + nglt
  359.   ngltr = nglr + nglrar  'total recoverable ngl
  360.   Call SizeClass(ngltr, maxfsc(14), marray, fsc) 'size class
  361.   snglr(3, fsc) = snglr(3, fsc) + ngltr
  362.   TotR(7) = TotR(7) + ngltr
  363.  End If
  364.  TotClos = TotClos + z(2)
  365.  If i <= 100 Then
  366.   If os = 1 Then
  367.    Write #3, i, njknt, os, z(6), z(1), z(2), z(3), z(4), z(5)
  368.   Else
  369.    Write #3, i, njknt, os, z(6), z(1), z(2), z(3), z(4), z(5)
  370.   End If
  371.  End If
  372.  If os = 1 Then
  373.   Write #1, i, njknt, os, OilR, z(2), depth, adgr, nglr, fvf, GOR, nglratio
  374.  Else
  375.   Write #1, i, njknt, os, GasR, z(2), depth, ngltr, press, temp, zc, nglratio
  376.  End If
  377. End If
  378. ' no reservoir
  379. Next nj   'end of prospect loop
  380.  
  381. If TotClos > Mclos Then Mclos = TotClos
  382. If TotClos > playa Then Ntotc = Ntotc + 1
  383.  
  384. Write #2, i, TotR(1), TotR(2), TotR(3), TotR(4), TotR(5), TotR(6), TotR(7), TotIP(1), TotIP(2), TotIP(3), TotIP(4), TotIP(5), TotIP(6), TotIP(7)
  385. For j = 1 To 7
  386.  tmpIP = TotIP(j) - c(j)
  387.  tmpR = TotR(j) - c(j) * 0.5
  388.  SumIP(j) = SumIP(j) + tmpIP
  389.  SumR(j) = SumR(j) + tmpR
  390.  Sum2IP(j) = Sum2IP(j) + tmpIP * tmpIP
  391.  Sum2R(j) = Sum2R(j) + tmpR * tmpR
  392. Next j
  393. For j = 1 To 2
  394.  NumDep(j) = NumDep(j) + NDRep(j)
  395.  NumDep(j + 2) = NumDep(j + 2) + NDRep(j) * NDRep(j)
  396. Next j
  397.  
  398. Next i    'end of simulation loop
  399.  
  400. 'Summary statistics
  401. ' get averages by size class
  402.  
  403. For i = 1 To 7
  404.  Sum2IP(i) = Sqr((Sum2IP(i) - (SumIP(i) / mdiv) * SumIP(i)) / (mdiv - 1))
  405.  Sum2R(i) = Sqr((Sum2R(i) - (SumR(i) / mdiv) * SumR(i)) / (mdiv - 1))
  406.  SumIP(i) = SumIP(i) / mdiv + c(i)
  407.  SumR(i) = SumR(i) / mdiv + c(i) * 0.5
  408. Next i
  409. For j = 1 To 2
  410.  NumDep(j + 2) = Sqr((mdiv * NumDep(j + 2) - NumDep(j) * NumDep(j)) / ((mdiv - 1) * mdiv))
  411.  NumDep(j) = NumDep(j) / mdiv
  412. Next j
  413. For j = 1 To marray
  414.  For i = 1 To 2
  415.   so(i, j) = so(i, j) / mdiv
  416.   sor(i, j) = sor(i, j) / mdiv
  417.  Next i
  418.  For i = 1 To 3
  419.   sngl(i, j) = sngl(i, j) / mdiv
  420.   snglr(i, j) = snglr(i, j) / mdiv
  421.  Next i
  422.  For i = 1 To 4
  423.   sg(i, j) = sg(i, j) / mdiv
  424.   sgr(i, j) = sgr(i, j) / mdiv
  425.  Next i
  426. Next j
  427.  
  428. Pclos = 100 * Ntotc / m
  429.  
  430. 'Output statistics
  431. Worksheets("Summary").Activate 'in place mean and std dev
  432.   Range("b5").Select
  433.    Selection.Value = SumIP(1)
  434.   Range("c5").Select
  435.    Selection.Value = Sum2IP(1)
  436.   Range("b7").Select
  437.    Selection.Value = SumIP(2)
  438.   Range("c7").Select
  439.    Selection.Value = Sum2IP(2)
  440.   Range("b8").Select
  441.    Selection.Value = SumIP(3)
  442.   Range("c8").Select
  443.    Selection.Value = Sum2IP(3)
  444.   Range("b9").Select
  445.    Selection.Value = SumIP(4)
  446.   Range("c9").Select
  447.    Selection.Value = Sum2IP(4)
  448.   Range("b11").Select
  449.    Selection.Value = SumIP(5)
  450.   Range("c11").Select
  451.    Selection.Value = Sum2IP(5)
  452.   Range("b12").Select
  453.    Selection.Value = SumIP(6)
  454.   Range("c12").Select
  455.    Selection.Value = Sum2IP(6)
  456.   Range("b13").Select
  457.    Selection.Value = SumIP(7)
  458.   Range("c13").Select
  459.    Selection.Value = Sum2IP(7)
  460.   Range("b17").Select            'recoverable mean and std dev
  461.    Selection.Value = SumR(1)
  462.   Range("c17").Select
  463.    Selection.Value = Sum2R(1)
  464.   Range("b19").Select
  465.    Selection.Value = SumR(2)
  466.   Range("c19").Select
  467.    Selection.Value = Sum2R(2)
  468.   Range("b20").Select
  469.    Selection.Value = SumR(3)
  470.   Range("c20").Select
  471.    Selection.Value = Sum2R(3)
  472.   Range("b21").Select
  473.    Selection.Value = SumR(4)    ' Mean NA Gas
  474.   Range("c21").Select
  475.    Selection.Value = Sum2R(4)
  476.   Range("b23").Select
  477.    Selection.Value = SumR(5)
  478.   Range("c23").Select
  479.    Selection.Value = Sum2R(5)
  480.   Range("b24").Select
  481.    Selection.Value = SumR(6)    ' Mean NA Gas
  482.   Range("c24").Select
  483.    Selection.Value = Sum2R(6)
  484.   Range("b25").Select
  485.    Selection.Value = SumR(7)
  486.   Range("c25").Select
  487.    Selection.Value = Sum2R(7)
  488.   Range("b28").Select
  489.    Selection.Value = NumDep(1)  ' Number of pools, mean and std.dev
  490.   Range("c28").Select
  491.    Selection.Value = NumDep(3)
  492.   Range("b29").Select
  493.    Selection.Value = NumDep(2)
  494.   Range("c29").Select
  495.    Selection.Value = NumDep(4)
  496.  
  497.   Range("b32").Select
  498.    Selection.Value = m      'number of simulations
  499.   Range("b33").Select
  500.    Selection.Value = mdiv   'number of play runs
  501.    
  502. Worksheets("Distns").Activate
  503.   Range("b5:n6").Select     'in place
  504.    Selection.Value = so     'num and oil
  505.   Range("b9:n12").Select
  506.    Selection.Value = sg     'num NA gas, ass dis gas & NA gas
  507.   Range("b16:n18").Select
  508.    Selection.Value = sngl   'ngl from ass dis gas & NA gas
  509.   Range("b22:n23").Select   'recoverable
  510.    Selection.Value = sor    'num and oil
  511.   Range("b26:n29").Select
  512.    Selection.Value = sgr    'num NA gas, ass dis gas & NA gas
  513.   Range("b33:n35").Select
  514.    Selection.Value = snglr  'ngl from ass dis gas & NA gas
  515.     
  516. Worksheets("Supple").Activate
  517.   Range("e5").Select
  518.    Selection.Value = Mclos   'Max area of closures
  519.   Range("e6").Select
  520.    Selection.Value = Pclos   '%total closure>play area|success
  521.   Range("e13:r13").Select
  522.    Selection.Value = maxfsc  'Max field size classes
  523.   Range("e8").Select
  524.    Selection.Value = marray  'Max num log 2 size classes
  525.   Range("e3").Select
  526.    Selection.Value = seed    'Random number seed
  527. Close #1
  528. Close #2
  529. Close #3
  530.  
  531. End Sub
  532. Sub SampleOHVP(z, pd, fvf, minfs)
  533. ' Computes Oil in place >= cutoff
  534. '  Note correlation between z(3) [porosity] and
  535. '   z(4)[1-ws] is one.
  536. Dim prod As Variant, j As Integer, k As Integer, u As Variant
  537. Dim j2 As Integer
  538. Line1:
  539.  prod = 1
  540.   For j = 1 To 5
  541.     If j <> 4 Then u = Rnd
  542.     j2 = j * 2 - 1
  543.      For k = 2 To 7
  544.        If u > pd(k - 1, j2 + 1) And u <= pd(k, j2 + 1) Then
  545.          z(j) = pd(k - 1, j2) + ((u - pd(k - 1, j2 + 1)) / (pd(k, j2 + 1) - pd(k - 1, j2 + 1))) * (pd(k, j2) - pd(k - 1, j2))
  546.          prod = prod * z(j)
  547.        End If
  548.      Next k
  549.   Next j
  550. ' in place oil in millions of bbl
  551. z(6) = prod * 7.758 * 10 ^ -6 / fvf
  552. If z(6) >= minfs Then
  553.  Exit Sub
  554. Else
  555.  GoTo Line1
  556. End If
  557. End Sub
  558. Sub SampleGHVP(z, pd, zc, temp, press, minfs)
  559. ' Computes Gas in place >= cutoff
  560. '  Note correlation between z(3) and z(4) is one.
  561. Dim prod As Variant, j As Integer, k As Integer, u As Variant
  562. Dim j2 As Integer
  563. Line1:
  564.  prod = 1
  565.   For j = 1 To 5
  566.     If j <> 4 Then u = Rnd
  567.     j2 = j * 2 - 1
  568.      For k = 2 To 7
  569.        If u > pd(k - 1, j2 + 1) And u <= pd(k, j2 + 1) Then
  570.          z(j) = pd(k - 1, j2) + ((u - pd(k - 1, j2 + 1)) / (pd(k, j2 + 1) - pd(k - 1, j2 + 1))) * (pd(k, j2) - pd(k - 1, j2))
  571.          prod = prod * z(j)
  572.        End If
  573.      Next k
  574.   Next j
  575. 'in place gas in billions of cu ft
  576. z(6) = prod * 0.00000154 * (press / temp) / zc
  577. ' 1540e-09=43.56 * 10 ^ -9 * (519.7 / 14.7)
  578. If z(6) / 6 >= minfs Then
  579.  Exit Sub
  580. Else
  581.  GoTo Line1
  582. End If
  583. End Sub
  584. Sub SingleS(pd, j, z)
  585. ' Random Deviate from Fractile Distribution
  586. Dim k As Integer, u As Variant
  587.  
  588.    u = Rnd
  589.     For k = 2 To 7
  590.        If u > pd(k - 1, j + 1) And u <= pd(k, j + 1) Then
  591.          z = pd(k - 1, j) + ((u - pd(k - 1, j + 1)) / (pd(k, j + 1) - pd(k - 1, j + 1))) * (pd(k, j) - pd(k - 1, j))
  592.        End If
  593.     Next k
  594. End Sub
  595. Sub SizeClass(size, maxf, marray, fsc)
  596. ' Computes size class in log based 2
  597.  fsc = Int(Log(size) / Log(2)) - 1 ' size class
  598.   If fsc < 1 Then fsc = 1
  599.   If fsc > maxf Then maxf = fsc
  600.   If fsc > marray Then fsc = marray
  601.  End Sub
  602. Sub gasc(p0, t0, depth, z)
  603. 'Estimates gas compressibility
  604. '  Ref: Microcomputer Programs for Petroleum Engineers
  605. '  p- pressure
  606. '  t- degrees Rankine
  607. '  depth- 1000 ft
  608. '  z- gas compressibility
  609.  
  610. Dim dr(1 To 6), drp(1 To 6)
  611. Dim i, k As Integer
  612. Dim a, b, c, e, f, g, t2, fdr, gdr, t, p As Variant
  613. If depth <= 3 Then      'depth <=3,000 ft
  614.   z = 1 - 0.11 * depth + 0.0125 * depth * depth
  615.   Exit Sub
  616. End If
  617. ' Use Mricocompute algorithm for depths > 3000 ft
  618. ' t and p are reducted temperature and pressure
  619. '  using gas gravity of 0.6 and Fig 17 furnished by
  620. '  John Quinn
  621. t = t0 / 358
  622. p = p0 / 672
  623. a = 0.06423
  624. f = 0.6845
  625. dr(1) = 0.27 * p / t
  626.  
  627. b = 0.5353 * t - 0.6123
  628. t2 = t * t
  629. c = 0.3151 * t - 1.0467 - (0.5783 / t2)
  630. e = 0.6816 / t2
  631. g = 0.27 * p
  632. For i = 1 To 5
  633. drp(1) = dr(i)
  634. For k = 2 To 6
  635.  drp(k) = drp(k - 1) * drp(1)
  636. Next k
  637. fdr = a * drp(6) + b * drp(3) + c * drp(2) + t * drp(1) + e * drp(3) * (1 + f * drp(2)) * Exp(-f * drp(2)) - g
  638. gdr = 6 * a * drp(5) + 3 * drp(2) + 2 * c * drp(1) + t + e * drp(2) * (3 + f * drp(2) * (3 - 2 * f * drp(2))) * Exp(-f * drp(2))
  639. dr(i + 1) = dr(i) - fdr / gdr
  640. Next i
  641. z = dr(6)
  642. End Sub
  643. 1
  644.  
  645.  
  646. 1
  647.  
  648.  
  649.